home *** CD-ROM | disk | FTP | other *** search
/ Languguage OS 2 / Languguage OS II Version 10-94 (Knowledge Media)(1994).ISO / gnu / libg_261.zip / libg_261 / libg++ / src / gen / XPBag.hP < prev    next >
Text File  |  1992-12-22  |  2KB  |  99 lines

  1. // This may look like C code, but it is really -*- C++ -*-
  2. /* 
  3. Copyright (C) 1988 Free Software Foundation
  4.     written by Doug Lea (dl@rocky.oswego.edu)
  5.  
  6. This file is part of the GNU C++ Library.  This library is free
  7. software; you can redistribute it and/or modify it under the terms of
  8. the GNU Library General Public License as published by the Free
  9. Software Foundation; either version 2 of the License, or (at your
  10. option) any later version.  This library is distributed in the hope
  11. that it will be useful, but WITHOUT ANY WARRANTY; without even the
  12. implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
  13. PURPOSE.  See the GNU Library General Public License for more details.
  14. You should have received a copy of the GNU Library General Public
  15. License along with this library; if not, write to the Free Software
  16. Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
  17. */
  18.  
  19.  
  20. #ifndef _<T>XPBag_h
  21. #ifdef __GNUG__
  22. #pragma interface
  23. #endif
  24. #define _<T>XPBag_h 1
  25.  
  26. #include "<T>.Bag.h"
  27. #include "<T>.XPlex.h"
  28.  
  29. class <T>XPBag : public <T>Bag
  30. {
  31. protected:
  32.   <T>XPlex              p;
  33.  
  34. public:
  35.                 <T>XPBag(int chunksize = DEFAULT_INITIAL_CAPACITY);
  36.                 <T>XPBag(const <T>XPBag&);
  37.  
  38.   Pix           add(<T&> item);
  39.   void          del(<T&> item);
  40. #undef remove
  41.   void          remove(<T&>item);
  42.   int           nof(<T&> item);
  43.   int           contains(<T&> item);
  44.  
  45.   void          clear();
  46.  
  47.   Pix           first();
  48.   void          next(Pix& i);
  49.   <T>&          operator () (Pix i);
  50.   int           owns(Pix i);
  51.   Pix           seek(<T&> item, Pix from = 0);
  52.  
  53.   int           OK();
  54. };
  55.  
  56.  
  57. inline <T>XPBag::<T>XPBag(int chunksize) 
  58.      : p(chunksize) { count = 0; }
  59.  
  60. inline <T>XPBag::<T>XPBag(const <T>XPBag& s) : p(s.p) { count = s.count; }
  61.  
  62. inline Pix <T>XPBag::first()
  63. {
  64.   return p.first();
  65. }
  66.  
  67. inline void <T>XPBag::next(Pix  & idx)
  68. {
  69.   p.next(idx);
  70. }
  71.  
  72. inline <T>& <T>XPBag::operator ()(Pix   idx)
  73. {
  74.   return p(idx);
  75. }
  76.  
  77. inline void <T>XPBag::clear()
  78. {
  79.   count = 0;  p.clear();
  80. }
  81.  
  82. inline int <T>XPBag::owns (Pix   idx)
  83. {
  84.   return p.owns(idx);
  85. }
  86.  
  87. inline Pix <T>XPBag::add(<T&> item)
  88. {
  89.   ++count;
  90.   return p.index_to_Pix(p.add_high(item));
  91. }
  92.  
  93. inline int <T>XPBag::contains(<T&> item)
  94. {
  95.   return seek(item) != 0;
  96. }
  97.  
  98. #endif
  99.